package android.demo;

import android.app.ListActivity;
import android.content.Intent;
import android.demo.activity.ActivityList;
import android.demo.broadcast.BroadcastActivity;
import android.demo.handler.HandlerActivityD;
import android.demo.service.ServiceActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MainActivity extends ListActivity {

	private static final int ACTIVITY = 0;
	private static final int BROADCAST = 1;
	private static final int SERVICE = 2;
	private static final int HANDLER = 3;
	
	public void onCreate(Bundle savedInstanceState) {  
		super.onCreate(savedInstanceState);  
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
				android.R.layout.simple_expandable_list_item_1,  
				new String[] {"Activity", "BroadcastReceiver", "Service", "Handler"});
		setListAdapter(adapter); 
	}  
	
	protected void onListItemClick(ListView l, View v, int position, long id) {  
		super.onListItemClick(l, v, position, id);  
		switch (position) {
			case ACTIVITY :
				startActivity(new Intent(this, ActivityList.class));
				break;
			case BROADCAST :
				startActivity(new Intent(this, BroadcastActivity.class));
				break;
			case SERVICE :
				startActivity(new Intent(this, ServiceActivity.class));
				break;
			case HANDLER :
				startActivity(new Intent(this, HandlerActivityD.class));
				break;
		}
	}  
}
